<?php

if(!defined('IN_AACMS')) {
	exit('Access Denied');
}

if(submitcheck('messagesubmit')) {
	
	$_POST['name'] = strip_tags($_POST['name']);
	$_POST['content'] = strip_tags($_POST['content']);
	
	if(!$_POST['name'] || !$_POST['content']) {
		showmessage('info_incomplete', dreferer());
	}
	
	$setarr = array(
		'name' => $_POST['name'],
		'content' => $_POST['content'],
		'status' => 1,
		'ip' => $_G['clientip'],
		'create_date' => TIMESTAMP
	);
	
	if(DB::insert('message_board', $setarr)) {
		showmessage('do_success', dreferer());
	} else {
		showmessage('do_error', dreferer());
	}
}

$perpage = 10;
$page = $_GET['page'] ? max(intval($_GET['page']), 1) : 1;
$start = ($page - 1) * $perpage;

$count = DB::getOne("SELECT COUNT(*) FROM ".DB::table('message_board')." WHERE status='0'");
$list = DB::getAll("SELECT * FROM ".DB::table('message_board')." WHERE status='0' ORDER BY mid DESC LIMIT $start,$perpage");
$multipage = multi($count, $perpage, $page, 'misc.php?mod=messageboard');

include template('misc/messageboard');

?>